#!/bin/bash
# 股票分析工具卸载脚本
# 用法: sudo bash uninstalla股.sh

set -e

# 配置区（必须与安装脚本一致）
APP_NAME="eagle_eyes"
DISPLAY_NAME="鹰眼"
INSTALL_DIR="/opt/$APP_NAME"
BIN_LINK="/usr/local/bin/$APP_NAME"
DESKTOP_FILE="/usr/share/applications/$APP_NAME.desktop"
ICON_SIZES=(16 32 48 64 128 256 512)

# 执行卸载
echo "[1/4] 移除程序文件..."
sudo rm -rfv "$INSTALL_DIR"
sudo rm -fv "$BIN_LINK"
sudo rm -fv "$DESKTOP_FILE"

echo "[2/4] 清理图标文件..."
for size in "${ICON_SIZES[@]}"; do
    sudo rm -fv "/usr/share/icons/hicolor/${size}x${size}/apps/$APP_NAME.png"
done

echo "[3/4] 更新系统数据库..."
sudo update-desktop-database
sudo gtk-update-icon-cache -f /usr/share/icons/hicolor/

echo -e "\n\e[32m[4/4] 卸载完成！\e[0m"
